// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import MintUI from 'mint-ui'
import 'mint-ui/lib/style.css'
import App from './App'
import router from './router'
import { $http, $userhttp } from './requests'
import store from './store'
// 引入之后将ajax配置到原型上
Vue.prototype.$http = $http
Vue.prototype.$userhttp = $userhttp
Vue.use(MintUI)
// Vue.use(InfiniteScroll);
Vue.config.productionTip = false
// 权限认证
router.beforeEach((to, from, next) => {
  if (to.meta.isAuthRequired && store.state.user.isLogin === false) {
    next({
      name: 'login',
      params: {
        to: to.path
      }
    })
  } else {
    next()
  }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
// 全局挂store
